package com.hci.mercatinidinatale;

import com.hci.mercatinidinatale.db.Mercatino;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class RicercaAlloggio extends Activity
{

	Mercatino mercatino;
	WebView wv;
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_ricerca_alloggio);
		
		Intent i = getIntent();
		
		mercatino = (Mercatino)i.getSerializableExtra("mercatino");
		
		wv = (WebView)findViewById(R.id.webView1);
		wv.getSettings().setJavaScriptEnabled(true);  
        wv.getSettings().setLoadsImagesAutomatically(true);         
        wv.setWebViewClient(new WebViewClient());  
        wv.loadUrl("http://www.tripadvisor.it");  
	}
	
	@Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
	{
        if(event.getAction() == KeyEvent.ACTION_DOWN)
        {
            switch(keyCode)
            {
            case KeyEvent.KEYCODE_BACK:
                if(wv.canGoBack() == true){
                    wv.goBack();
                }else{
                    finish();
                }
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }
}
